package com.zone.domain.acticity.service;

import com.zone.domain.acticity.model.entity.ActivityCountEntity;
import com.zone.domain.acticity.model.entity.ActivityEntity;
import com.zone.domain.acticity.model.entity.ActivitySkuEntity;
import com.zone.domain.acticity.repository.IActivityRepository;
import org.apache.commons.lang3.Validate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author: zongzi
 * @description: 活动下单支撑类。提供活动相关查询接口，并且校验活动数据
 * @date: 2024/7/15
 */
@Service
public class ActivitySupport {
    @Autowired
    private IActivityRepository activityRepository;

    public ActivitySkuEntity queryActivitySku(Long sku) {
        // 查询活动sku信息
        ActivitySkuEntity activitySku = activityRepository.queryActivitySku(sku);
        Validate.notNull(activitySku, "未知的活动库存！");
        return activitySku;
    }

    public ActivityEntity queryActivity(Long activityId) {
        // 查询活动信息
        ActivityEntity activity = activityRepository.queryActivity(activityId);
        Validate.notNull(activity, "未知的活动！");
        return activity;
    }

    public ActivityCountEntity queryActivityCount(Long activityCountId) {
        // 查询活动次数配置信息
        ActivityCountEntity activityCount = activityRepository.queryActivityCount(activityCountId);
        Validate.notNull(activityCount, "未知的活动次数配置！");
        return activityCount;
    }
}
